﻿
using Xacml.Core;
using Xacml.Core.Interfaces;
using System.Xml;

namespace Xacml.Core.Policy
{
  public abstract class AttributeReferenceBase : XacmlElement, IExpression
  {
    private string _dataType;
    private bool _mustBePresent;

    public string DataType
    {
      get
      {
        return this._dataType;
      }
      set
      {
        this._dataType = value;
      }
    }

    public bool MustBePresent
    {
      get
      {
        return this._mustBePresent;
      }
      set
      {
        this._mustBePresent = value;
      }
    }

    protected AttributeReferenceBase(string dataType, bool mustBePresent, XacmlVersion schemaVersion)
      : base(XacmlSchema.Policy, schemaVersion)
    {
      this._dataType = dataType;
      this._mustBePresent = mustBePresent;
    }

    protected AttributeReferenceBase(XmlReader reader, XacmlVersion schemaVersion)
      : base(XacmlSchema.Policy, schemaVersion)
    {
      this._dataType = reader.GetAttribute("DataType");
      this._mustBePresent = bool.Parse(reader.GetAttribute("MustBePresent"));
    }

    public abstract void WriteDocument(XmlWriter writer);
  }
}
